package com.lysj.admin.gateway.constants;

import cn.hutool.core.codec.Base64;
import com.lysj.admin.utils.json.JacksonUtil;
import com.lysj.admin.utils.web.ParamUtil;

import java.util.Map;

/**
 * @author Created by zk on 2019-01-16 16:04
 * @description
 */
public class JwtUtils {
    public static String tokenIssValue(String token){
        if(ParamUtil.isBlank(token)){
            return "";
        }
        String[] tokenParts = token.split("\\.");
        if(tokenParts.length != 3){
            return "";
        }
        String payloadStr = tokenParts[1];
        String payloadJson = Base64.decodeStr(payloadStr);
        Map<String,String> payloadMap = JacksonUtil.toStringMap(payloadJson);
        return payloadMap.get("iss");
    }
}
